package com.jp.knowledge.my.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.jp.knowledge.R;
import com.jp.knowledge.my.base.RecycleVAdapter;
import com.jp.knowledge.my.base.RecycleVHolder;
import com.jp.knowledge.my.model.OptionSelectModel;

import org.xutils.common.util.DensityUtil;

import java.util.List;

/**
 * @author gzejia 978862664@qq.com
 */
public class MyMoreAdapter extends RecycleVAdapter<OptionSelectModel> {

    public MyMoreAdapter(Context context, @NonNull List<OptionSelectModel> list) {
        super(context, list);
    }

    @Override
    public int getLayoutId(int viewType) {
        return R.layout.item_my_more;
    }

    @Override
    public void onBind(RecycleVHolder holder, int position) {
        OptionSelectModel  model = getData(position);
        int size = 4;
//        if(size>0&&size<=5)
        holder.getConvertView().setLayoutParams(
                new LinearLayout.LayoutParams(DensityUtil.getScreenWidth()/ size, LinearLayout.LayoutParams.WRAP_CONTENT));
        holder.setTextView(R.id.my_item_tv_value, model.mContent);
        holder.setImageResource(R.id.my_item_iv_icon, model.mImage);
        TextView   tip = holder.getTextView(R.id.tip_text);

        if(model.showTip){
            tip.setText(model.tipCount+"");
            tip.setVisibility(View.VISIBLE);
        }else {
            tip.setVisibility(View.GONE);
        }

    }
}
